/*
 * Created on 02.02.2004
 */
package ro.qi.framework.sys.repository;

/**
 * @author vlad lepadatu 
 */
public class ActionElement {

	public static final int NONE				= 0;
	public static final int IN					= 1;
	public static final int OUT					= 2;
	
	//	used to keep simple text into the componentName member
	public static final int TYPE_NONE			= 0;
	public static final int TYPE_NUMERIC		= 1;
	public static final int TYPE_VARCHAR		= 2;
	public static final int TYPE_VARCHAR2		= 3;
	public static final int TYPE_DATE			= 4;
	public static final int TYPE_ORACLE_CURSOR	= 5;
	public static final int TYPE_ORACLE_CLOB	= 6;
	public static final int TYPE_ORACLE_BLOB	= 7;
	public static final int TYPE_COLLECTION		= 8;
	public static final int TYPE_NVARCHAR		= 9;
	public static final int TYPE_BLOB			= 10;
	public static final int TYPE_CLOB			= 11;
	public static final int TYPE_FLOAT			= 12;
	public static final int TYPE_BOOLEAN		= 13;

	private String componentName = null;					// name of the component
	private int input = NONE;								// is input or output component (in, out)
	private int type = TYPE_NONE;							// type of the component (number, varchar ...)
	private String extra = null;							// extra information

	/**
	 * @return
	 */
	public String getComponentName() {
		return componentName;
	}

	/**
	 * @return
	 */
	public int getType() {
		return type;
	}

	/**
	 * @param string
	 */
	public void setComponentName(String string) {
		componentName = string;
	}

	/**
	 * @param i
	 */
	public void setType(int i) {
		type = i;
	}
	
	public void setType(String string) {
		if( string.toLowerCase().equals("number") )
			type = TYPE_NUMERIC;
		else if( string.toLowerCase().equals("varchar") )
			type = TYPE_VARCHAR;
		else if( string.toLowerCase().equals("varchar2") )
			type = TYPE_VARCHAR2;
		else if( string.toLowerCase().equals("date") )
			type = TYPE_DATE;
		else if( string.toLowerCase().equals("oraclecursor") )
			type = TYPE_ORACLE_CURSOR;
		else if( string.toLowerCase().equals("oracleclob") )
			type = TYPE_ORACLE_CLOB;
		else if( string.toLowerCase().equals("oracleblob") )
			type = TYPE_ORACLE_BLOB;
		else if( string.toLowerCase().equals("collection") )
			type = TYPE_COLLECTION;
		else if( string.toLowerCase().equals("nvarchar") )
			type = TYPE_NVARCHAR;
		else if( string.toLowerCase().equals("blob") )
			type = TYPE_BLOB;
		else if( string.toLowerCase().equals("clob") )
			type = TYPE_CLOB;
		else if( string.toLowerCase().equals("float") )
			type = TYPE_FLOAT;
		else if( string.toLowerCase().equals("boolean") )
			type = TYPE_BOOLEAN;
	}

	public void setInput(String string) {
		if( string.toLowerCase().equals("in") )
			input = IN;
		else
			input = OUT;
	}

	/**
	 * @return
	 */
	public boolean isInput() {
		return input == IN;
	}

	/**
	 * @return
	 */
	public boolean isOutput() {
		return input == OUT;
	}

	/**
	 * @param b
	 */
	public void setInput(boolean b) {
		if( b )
			input = IN;
		else
			input = OUT;
	}

	/**
	 * @return
	 */
	public String getExtra() {
		return extra;
	}

	/**
	 * @param string
	 */
	public void setExtra(String string) {
		extra = string;
	}

}
